<!--/**
* @author xuyh0817
* @email xuyh0817@foxmail.com
* @date 2022-02-16 15:58
* @version 2.0.0
* @doc todo
* @website todo
* @remark  如果要分发源码，需在本文件顶部保留此文件头信息！！
*/
-->
<template>
  <a-input
    :value="currentValue"
    v-bind="attrs"
    @change="changeHandler"
  >
<!--    <extend-slot v-for="(render, key) of slots" v-slot:[key] :key="key" :data="slotData" :render="render"/>-->
  </a-input>
</template>

<script>
import {COMPONENT_TYPE, CUSTOM_EVENT_TYPE} from '../../constants'
import ComponentMixin from '../../XRenderMixins/XRenderComponentMixin'

export default {
  name: COMPONENT_TYPE.INPUT,
  mixins: [ComponentMixin],
  props: {
    value: {
      type: [String, Number, Object, Array]
    }
  },
  computed: {
    currentValue: {
      get() {
        const {value} = this
        if (!!value && typeof (value) === 'object') {
          return JSON.stringify(value)
        }
        return value || ''
      }
    }
  },
  methods: {
    changeHandler(event) {
      const {formItem, attrs} = this
      const value = event.target.value
      this.$emit(CUSTOM_EVENT_TYPE.CHANGE, {
        type: COMPONENT_TYPE.INPUT,
        prop: formItem ? formItem.prop : '',
        value,
        attrs,
        formItem,
        event
      })
    }
  }
}
</script>

<style scoped>

</style>
